package com.example.crawler.youtube.extractor;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 从网站https://www.vidpaw.com/downloader/获取视频地址
 * @author Administrator
 */
@Component
public class VidpawExtractor extends ThirdPlatformExtractor {

    @Override
    public String name() {
        return "vidpaw";
    }


    @Override
    protected String getRequestUrl(String youtubeVideoUrl) {
        return "https://www.vidpaw.com/downl0ader/";
    }

    @Override
    protected Map<String, String> getRequestParameterMap(String youtubeVideoUrl) {
        Map<String, String> param = new HashMap<>(3);
        param.put("url", youtubeVideoUrl);
        param.put("format", "web");
        param.put("filter", "true");

        return param;
    }

    @Override
    protected Map<String, String> getHeaderFields(String youtubeVideoUrl) {
        String videoId = getVideoId(youtubeVideoUrl);
        Map<String, String> param = new HashMap<>(3);
        param.put("referer", String.format("https://www.vidpaw.com/download/%s/", videoId));
        return param;
    }

    @Override
    public int getOrder() {
        return 10;
    }
}
